package org.ycty.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.ycty.deale.swtSave;
import org.ycty.entity.Swt;

public class CreateSWTServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		request.setCharacterEncoding("utf-8");
		
		String pathname = request.getParameter("pathname");
		String webname = request.getParameter("webname");
		String weburl = request.getParameter("weburl");
		String swtjs = request.getParameter("swtjs");
		String nswtjs = "\""+swtjs+"\"";
		String bmgs = request.getParameter("bmgs");
		String khdm = request.getParameter("khdm");
		String other = null;
		
		Swt swt = new Swt(pathname,webname,weburl,nswtjs,bmgs,khdm,other);
		Boolean b = new swtSave().createSwt(swt);
		if(b){
			request.setAttribute("msg", "OK");
			request.getRequestDispatcher("swt.jsp").forward(request, response);
		}else{
			request.setAttribute("msg", "FAIL");
			request.getRequestDispatcher("swt.jsp").forward(request, response);
		}
		
	}

}
